﻿@model string
<div class="main no-padding no-border">
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered form-inline form-group-sm" id="tbList" data-source="@Html.GetDepartmentListJson()">
        <thead>
            <tr>
                <td style="width:45px">选择</td>
                <td>选择部门</td>
            </tr>
        </thead>
        <tr class="" id="tr_0" data-guid="" data-parentGuid="" data-isFinal="0" data-id="0">
            <td align="center"><input id="id" name="id" value="0" class="theid id_0 final_1" type="radio"></td>
            <td style="text-align:left" align="center"><span class="node node_1 file" guid=""></span><span>无部门</span></td>
        </tr>
        <tr class="item list-template-item parent_{parentGuid}" id='item_{id}' data-parentId="{parentId}" data-isFinal="{isFinal}" data-id="{id}">
            <td align="center"><input type="radio" id="id" name="id" value="{id}" class="theid id_{id} final_{isFinal}"></td>
            <td align="center" style="text-align:left">{space}<span class="node node_{isFinal}"></span><span>{name}</span></td>
        </tr>
    </table>


    <div class="footerarea">
        提示：请选择设置的部门！
    </div>

    <form class="form-group-sm form ui-validForm" method="post">
        <div class="submit-footerbar">
            <label class="control-label"></label>
            <input type="hidden" name="setValue" id="setValue" value="0" />
            <input type="hidden" name="setField" id="setField" value="departmentId" />
            <input type="hidden" name="ids" id="ids" value="@Request.QueryString["ids"]" />
            <button type="button" class="btn btn-sm  btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl("DepartmentSet")',beforeExecute:'BeforeExecuting',callBack:'PostCloseRefreshBack'">设置</button>
            <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
        </div>
    </form>
</div>
<script type="text/javascript">

    function LoadData() {
        $("#tbList").TreeBind({ dataSourceFrom: "attr", showFooter: false, callBack: "LoadedInit" });
    }

    function LoadedInit() {
        $(".final_0").attr("disabled", "disabled");
    }
    LoadData();

    function BeforeExecuting() {
        var id = $(".theid").GetChecked();
        if (id == "") {
            Alert("请选择要设置的部门!")
            return false;
        }
        $("#setValue").val(id);

        var $parentObj = parent.$(".checked-item");
        var ids = $parentObj.GetValue();
        $("#ids").val(ids);

        return true;
    }


    function CallBack() {
        PostBack();
        CloseDialog();
    }
</script>

